<?php
/**
 * Created by PhpStorm.
 * User: guokunsheng
 * Date: 2022/5/24
 * Time: 下午8:12
 */

namespace app\api\controller\v32;

use app\api\controller\v13\Auth2;
use app\common\cachemodel\lucky\AppUserAdornInfo;
use app\common\cachemodel\ZlGoddessState;
use app\common\lib\ConfigManage;

/**
 * Class Video
 * @package app\api\controller\v32
 */
class Video extends Auth2
{
    /**
     * 获取视频列表
     */
    public function videoList()
    {
        $type = input('type/d', 2);//[1=>星文，2=>女神动态，3=>女神专区]
        $aid = input('aid/d', 0);
        $limit = input('page_size/d', 10);
        $limit = $limit > 10 ? 10 : $limit;
        $stateModel = new ZlGoddessState();
        $video = $stateModel->getGoddessStateIdsFromCache($this->user, $aid, $limit);
        $configModel = new ConfigManage();
        $arr = [];
        foreach ($video['data'] as $item)
        {
            // 获取用户当前装扮信息 1=>官方，2=>女神
            $adorn = (new AppUserAdornInfo())->getUserAdornInfo(0, $item['author_type']);
            $arr[] = [
                'video_url' => $item['url'],
                'duration' => $item['duration'],
                'aid' => $item['id'],
                'type' => $item['type'],
                'author' => $item['author'],
                'avatar' => $item['avatar'],
                'title' => $item['title'],
                'intro' => $item['introduction'],
                'is_good' => $item['is_good'],
                'is_collect' => $item['is_collect'],
                'thumb' => $item['thumb'],
                'user_type' => $configModel->innerUser((int)($item['a_id'] ?? 0)),//判断作者用户类型
                'ad_info' => $item['ad_info'],
                'good_num' => (int)$item['good_num'],
                'comment_num' => (int)$item['comment_num'],
                'collect_num' => (int)$item['collect_num'],
                'release_time' => $item['release_time'],
                // 新增作者头像框字段
                'avatar_adorn' => $adorn['adorn_info']['reality_img'],
            ];
        }
        $video['data'] = $arr;
        return show(config('code.success'), '获取成功', $video);
    }
}
